<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>dom</title>
	<style type="text/css">
	.box1{
		background:red;
		height:200px;
		width:200px;
	}
	.box2{
		background:gray;
		height:200px;
		width:200px;
	}
	</style>
	<script type="text/javascript">
	   window.onload=function(){
	         var box = document.getElementsByClassName('box1');
	         box[0].onclick=function(){
	    	alert('abc');
	              }
		        }
	</script>
	
</head>
<body>
  <div class="box1"></div>
  <div class="box2"></div>
</body>
</html>